﻿<%@ Page Title="" Language="C#" MasterPageFile="~/pages/master/WebList.Master" AutoEventWireup="true"
    CodeBehind="ChooseLowerOrganization.aspx.cs" Inherits="BF.Web.pages.BaseSystem.UserManagement.ChooseLowerOrganization" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<%@ Register Src="~/pages/UserControls/SysAreaTree.ascx" TagName="SysAreaControl"
    TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceJs" runat="server">
    <script type="text/javascript" language="javascript">

        function Confirm() {// 单选
            $("#ctl00_ContentPlaceHtml_isConfirmOrAllConfirm").val("1");
            SwitchFunction();
            return false;
        }

        function AllConfirm() {//全选
            $("#ctl00_ContentPlaceHtml_isConfirmOrAllConfirm").val("2");
            SwitchFunction();
            return false;
        }
        //验证与选择
        function SwitchFunction() {
            var isValue = $("#ctl00_ContentPlaceHtml_isConfirmOrAllConfirm").val(); // 获取 以判断是单选还是全选
            if (isValue == "1") {
                if ($("input[type=radio]:checked").length == 0) {
                    Ext.MessageBox.show({ title: '提示', msg: '请选一条记录！', buttons: { ok: '确  定' }, icon: 'ext-mb-info' });
                }
                else {
                    Ext.MessageBox.show({
                        title: "提示：",
                        msg: "确认选择？",
                        buttons: { "yes": '确  定', "no": '取 消' },
                        fn: function (result) {
                            if (result == 'yes') {
                                var obj = $("input[type=radio]:checked").parent().parent();
                                var model = Request("Model");
                                if (model == "Click")
                                    SetParentValueAndClick(obj);
                                else
                                    SetParentValue(obj);
                            }
                        },
                        icon: 'ext-mb-question'
                    });
                }
            } else {
                var obj = $("input[type=radio]:checked").parent().parent();
                var model = Request("Model");
                if (model == "Click")
                    SetParentValueAndClick(obj);
                else
                    SetParentValue(obj);
            }

            return false;
        }
        //向父窗体回传值
        function SetParentValue(obj) {
            var $this = $(obj);
            var id = $this.attr("id");
            var name = $this.attr("name");
            var code = $this.attr("code");
            var orgCode = $this.attr("orgcode");
            var obj = { gkey: "", sOrganizationName: "", areaCode: "", sOrganizationCode: "" };
            obj.gkey = id;
            obj.sOrganizationName = name;
            obj.areaCode = code;
            obj.sOrganizationCode = orgCode;
            winer.parentDom.SetValue(obj);
            winer.close();
        }

        //向父窗体回传值并单击父窗体按钮
        function SetParentValueAndClick(obj) {
            var isValue = $("#ctl00_ContentPlaceHtml_isConfirmOrAllConfirm").val(); // 获取 以判断是单选还是全选
            if (isValue == "1") {
                var $this = $(obj);
                var id = $this.attr("id");
                var name = $this.attr("name");
                var code = $this.attr("code");
                var obj = { gkey: "", sOrganizationName: "", areaCode: "" };
                obj.gkey = id;
                obj.sOrganizationName = name;
                obj.areaCode = code;
                winer.parentDom.SetValue(obj);
                winer.parentDom.document.getElementById("ctl00_ContentPlaceHtml_btnPostBack").click();
                winer.close();
            } else {
                var id = "";
                var name = "全部机构";
                var code = "";
                var obj = { gkey: "", sOrganizationName: "", areaCode: "" };
                obj.gkey = id;
                obj.sOrganizationName = name;
                obj.areaCode = code;
                winer.parentDom.SetValue(obj);
                winer.parentDom.document.getElementById("ctl00_ContentPlaceHtml_btnPostBack").click();
                winer.close();
            }
        }

        //单击行时选中RadioButton
        function SelectRadio(obj) {
            var $this = $(obj);
            $this.find("td").find("input[type=radio]").attr("checked", "true");
        }

        //截取URL参数
        function Request(paras) {
            var url = location.href;
            var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
            var paraObj = {}
            for (i = 0; j = paraString[i]; i++) {
                paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);
            }
            var returnValue = paraObj[paras.toLowerCase()];
            if (typeof (returnValue) == "undefined") {
                return "";
            } else {
                return returnValue;
            }
        }
    </script>
    <script type="text/javascript" language="javascript">
        //弹出查询窗体
        function Query() {
            Refurbish();
            return false;
        }

        //关闭弹出window时，执行的事件
        function Refurbish() {
            __doPostBack('ctl00$ContentPlaceHtml$AspNetPager1', '');
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHtml" runat="server">
    <table id="tabHead" width="100%" border="0" align="center" cellpadding="0" cellspacing="0"
        class="listtop1">
        <tr>
            <td id="QueryCondition" style="border-bottom: 1px solid #8db2e3;">
                <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" style="margin-bottom: 5px;
                    margin-top: 4px;" class="content04 ">
                    <tr>
                        <td align="right">
                            机构名称： </td>
                        <td>
                            <tll:DataTextBox ID="sOrganizationName" runat="server" Width="132px"></tll:DataTextBox>
                        </td>
                        <td align="right">
                            机构级别： </td>
                        <td>
                            <tll:DataDropDownList ID="sOrganizationLevel" runat="server" Width="132px">
                            </tll:DataDropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            机构类型： </td>
                        <td>
                            <tll:DataDropDownList ID="sOrganizationType" runat="server" Width="134px">
                            </tll:DataDropDownList>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td>
                <table id="" width="100%" border="0" align="center" cellpadding="0" cellspacing="0"
                    style="margin-bottom: 2px; margin-top: 2px; height: 26px;">
                    <tr>
                        <td>
                            <div class="btn01">
                                <asp:LinkButton ID="lbtnQuery" runat="server" OnClick="lbtnQuery_Click">
                            <span>
                                <img src="../../../images/search.png" alt="" border="0" /><div class="center">
                                    查询</div>
                            </span>
                                </asp:LinkButton>
                                <span style="margin-left: 250px; color: Red;">双击机构所在行选中机构</span>
                            </div>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <div id="div_scroll_x" class="div_scroll">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:Repeater ID="Repeater1" runat="server">
                    <HeaderTemplate>
                        <table id="tbList" width="100%" border="0" align="center" cellpadding="0" cellspacing="0"
                            class="list">
                            <thead>
                                <tr>
                                    <td align="left" style="width: 120px;">
                                        机构编码 </td>
                                    <td align="left" style="width: 250px;">
                                        机构名称 </td>
                                    <td align="left" style="width: 120px;">
                                        机构类型 </td>
                                    <td align="left" style="width: 120px;">
                                        机构级别 </td>
                                    <td align="left" style="width: 200px;">
                                        所属地区 </td>
                                </tr>
                            </thead>
                            <tbody>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <tr ondblclick="SetParentValue(this)" style="cursor: pointer" id='<%#Eval("gKey") %>'
                            code='<%#Eval("sAreaCode")%>' name='<%#Eval("sOrganizationName")%>' orgcode='<%#Eval("sOrganizationCode")%>'>
                            <td align="left">
                                <div class="divnr-auto" title='<%#Eval("sOrganizationCode")%>'>
                                    <%#Eval("sOrganizationCode")%></div>
                            </td>
                            <td align="left">
                                <div class="divnr-auto" title='<%#Eval("sOrganizationName")%>'>
                                    <%#Eval("sOrganizationName")%></div>
                            </td>
                            <td align="left">
                                <div class="divnr-auto" title='<%#GetOrganizationTypeName(Eval("sOrganizationType").ToString().Trim())%>'>
                                    <%#GetOrganizationTypeName(Eval("sOrganizationType").ToString().Trim())%></div>
                            </td>
                            <td align="left">
                                <div class="divnr-auto" title='<%#GetsOrganizationLevelName(Eval("sOrganizationLevel").ToString().Trim())%>'>
                                    <%#GetsOrganizationLevelName(Eval("sOrganizationLevel").ToString().Trim())%></div>
                            </td>
                            <td align="left">
                                <div class="divnr-auto" title='<%#GetDivisionName(Eval("sAreaCode").ToString())%>'>
                                    <%#GetDivisionName(Eval("sAreaCode").ToString())%></div>
                            </td>
                        </tr>
                    </ItemTemplate>
                    <FooterTemplate>
                        </tbody> </table>
                    </FooterTemplate>
                </asp:Repeater>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="AspNetPager1" EventName="PageChanged" />
                <asp:AsyncPostBackTrigger ControlID="lbtnQuery" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
    <asp:HiddenField ID="gHosptialKey" runat="server"></asp:HiddenField>
    <div class="div_AspNetPager">
        <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="fengye">
                    <tr>
                        <td>
                            <webdiyer:AspNetPager ID="AspNetPager1" runat="server" OnPageChanged="AspNetPager1_PageChanged"
                                meta:resourcekey="AspNetPager1" PageSize="15">
                            </webdiyer:AspNetPager>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="lbtnQuery" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
</asp:Content>
